<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <script src="../lib/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <router-link to="/account">account</router-link>

        <router-view></router-view>


    </div>
    <template id="temp1">
        <div>
            <h1>这是account组件</h1>
            <router-link to="/account/login">登录组件</router-link>
            <router-link to="/account/register">注册组件</router-link>
            <router-view></router-view>
        </div>
    </template>
    <template id="login">
        <h2>登录组件</h2>
    </template>
    <template id="register">
        <h2>注册组件</h2>
    </template>
    <script>
        var account = {
            template: '#temp1'
        }
        var login = {
            template: '#login'
        }
        var register = {
            template: '#register'
        }
        var router = new VueRouter({
            routes: [
                {   //路由的嵌套 使用children  子路由的路径不要带/
                    path: '/account', component: account, children: [
                        { path: 'login', component: login },
                        { path: 'register', component: register }
                    ]
                },
                // { path: '/account/login', component: login },
                // { path: '/account/register', component: register }
            ]
        })
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {

            },
            // router  属性名
            router: router
        })
    </script>
</body>

</html>